<?php

namespace App\Trip\Traits\Plane;

use Exception;

trait PlaneVendorsTrait
{

    /**
     * @throws Exception
     */
    public function getCompareVendors(): array
    {
        $price   = $this->getCheckPrice();
        $vendors = [
            ['name_show' => '某程', 'name' => '携程', 'rate' => 1.05],
            ['name_show' => '旅行社', 'name' => '旅行社', 'rate' => 1.12],
            ['name_show' => '代售点', 'name' => '代售点', 'rate' => 1.23],
        ];

        return collect($vendors)->map(function ($vendor) use ($price) {
            return [
                'name'    => $vendor['name_show'],
                'name_uy' => __($vendor['name']),
                'price'   => round($vendor['rate'] * $price),
            ];
        })->toArray();

    }
}